package com.example.registry;

import org.omg.CORBA.PUBLIC_MEMBER;

import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.rmi.server.RMIClientSocketFactory;
import java.rmi.server.RMIServerSocketFactory;

/**
 * @Description
 * @Author 26233
 * @Create 2021-11-02 18:34:21
 */

public class RmiServerConfig implements RMIServerSocketFactory, RMIClientSocketFactory {

    String configHost = "127.0.0.1";
    int configPort = 8888;

    public RmiServerConfig(){}
    public RmiServerConfig(String host, int port){
        this.configHost = host;
        this.configPort = port;
    }

    @Override
    public ServerSocket createServerSocket(int port) throws IOException {
        return new ServerSocket(this.configPort, 0, InetAddress.getByName(this.configHost));
    }

    @Override
    public Socket createSocket(String host, int port) throws IOException {
        return new Socket(this.configHost, this.configPort);
    }
}
